package cn.biplam.common.bean.systemManage;

import cn.biplam.common.bean.Bean;
import cn.biplam.common.paramters.SysName;
import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.KvMap;

/**
 * 产品管理
 * 
 * @author XiaoRuxing Nov 6, 20092:21:48 PM
 * @version 1.0
 */
public abstract class Product extends Bean {
	
	/** 模型是否发布 */
	private static KvMap<Modual_Name, Boolean> isDeploy;
	
	/**
	 *  模型名称
	 */
	public enum Modual_Name{
		DBS,
		Extract,
		Select,
		EDW,
		RULEENGINE;
	}

	/**
	 *  获取产品是否发布
	 * @return 产品是否发布
	 */
	public abstract boolean modelIsDeploy() throws ErrorMessage;
	
	/**
	 *  获取产品是否发布
	 * @return 产品是否发布
	 */
	public static boolean modelIsDeploy(Modual_Name name) throws ErrorMessage{
		if(isDeploy == null){
			isDeploy = new KvMap<Modual_Name, Boolean>();
		}
		if(isDeploy.getByKey(name) ==null){
			isDeploy.put(name, 
					Product.getNewInstance(SysName.SysUser, name.toString()).modelIsDeploy()
					);
		}
		return isDeploy.getByKey(name);
	}
	
	/**
	 * 新建实例
	 * @param userId  用户ID
	 * @param model
	 *            产品ID(类型:Modual_Name)
	 * @return Product实例
	 * @throws ErrorMessage
	 */
	public static Product getNewInstance(String userId ,String model) throws ErrorMessage {
		return (Product) get(Product.class.getSimpleName(), userId , model);
	}
}


